package com.yunc.modules.act.controller;

import com.yunc.common.utils.R;
import com.yunc.modules.act.service.IActivityConsumerService;
import org.activiti.engine.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * activity测试
 *
 * @author taocongcong
 * @create 2019-02-18 11:13
 */
@RestController
@RequestMapping("/acttest")
public class ActivityConsumerController {

    @Autowired
    private IActivityConsumerService activityConsumerService;
    @Autowired
    private TaskService taskService;

    @GetMapping(value="/activitiDemo")
    public R startActivityDemo (){
        activityConsumerService.startActivityDemo();
        return R.ok();
    }

    @GetMapping(value="/complete")
    public R complete (String taskId, String result){
        //查询当前审批节点
        /*Task vacationAudit = taskService.createTaskQuery()
                .taskId(taskId).singleResult();*/

        //taskService.setVariable(taskId, "result", result);
        //下一环节审核人
        //taskService.setVariable(taskId, "assignee", "cong");
        //taskService.setVariable(taskId, "assignee", "cong");
        //审核结果和审批意见
        Map<String, Object> variable = new HashMap<>();
        //variable.put("result", result);
        variable.put("assignee", "cong4");
        /*variable.put("result", result);
        variable.put("assignee", "cong");
        variable.put("comment", "同意");*/
        taskService.complete(taskId, variable, false);
        return R.ok();
    }
}
